import request from "@/utils/request";

const api_name = "/admin/system/sysRole";

export default {
  // 角色列表-条件分页查询
  getPageList(current, limit, searchObj) {
    return request({
      // url: '/admin/system/sysRole/getPageList/'+current+'/'+limit,
      url: `${api_name}/getPageList/${current}/${limit}`,
      method: "get",
      // 普通对象传递就是Params
      // 如果是json格式传递  data:对象格式传递
      params: searchObj,
    });
  },
  // 删除
  // /admin/system/sysRole/removeById/11
  removeById(id) {
    return request({
      url: `${api_name}/removeById/${id}`,
      method: "delete",
    });
  },
  //添加
  saveRole(role) {
    return request({
      url: `${api_name}/save`,
      method: "post",
      data: role,
    });
  },
  // 根据id查询
  getById(id) {
    return request({
      url: `${api_name}/getById/${id}`,
      method: "get",
    });
  },
  // 修改
  updateById(role) {
    return request({
      url: `${api_name}/update`,
      method: "put",
      data: role,
    });
  },
  // 批量删除
  batchRemove(idList) {
    return request({
      url: `${api_name}/batchRemove`,
      method: "delete",
      data: idList,
    });
  },
  getRoles(adminId) {
    return request({
      url: `${api_name}/toAssign/${adminId}`,
      method: "get",
    });
  },

  assignRoles(assginRoleVo) {
    return request({
      url: `${api_name}/doAssign`,
      method: "post",
      data: assginRoleVo,
    });
  },
};
